home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / hardware / cpu115 / p5info.asm < prev    next >
Assembly Source File  |  1995-02-27  |  2KB  |  124 lines

  1. ; -----------------------------------------------------------------------------
  2. ; P5INFO.ASM  Pentium Processor Feature Information          Version 1.01
  3. ;
  4. ; Copyright(c) 1994,95 by B-coolWare.  Written by Bobby Z.
  5. ; This code is part of TMi0SDGL(tm) CPU/FPU Feature Detection Library.
  6. ; -----------------------------------------------------------------------------
  7. ; These routines also work on new Intel and non-Intel 386 and 486 chips.
  8. ; You should check for 5 in chip family field to assure this is really P5
  9. ; and for GetVendor = 'GenuineIntel' to assure it is from Intel.
  10. ;
  11.  
  12.     INCLUDE    HEADER.ASH
  13.  
  14.     .CODE
  15.  
  16.     PUBLIC    CheckP5, GetP5Features, GetP5Vendor
  17.  
  18. ; GetP5Features returns word with following bitfields:
  19.  
  20. FPUonChip        equ    0000000001b
  21. EnhancedV86        equ    0000000010b
  22. IOBreakPoints        equ    0000000100b
  23. PageSizeExtensions    equ    0000001000b
  24. TimeStampCounter    equ    0000010000b
  25. ModelSpecificRegisters    equ    0000100000b
  26. MachineCheckException    equ    0010000000b
  27. CMPXCHG8BInstruction    equ        0100000000b
  28. APIConChip        equ    1000000000b
  29.  
  30. ; CheckP5 returns word with following bitfields:
  31.  
  32. chipInfo    record chipFamily:4, chipModel:4, chipStep:4
  33.  
  34. EF_ID    equ    00200000h    ; ID flag in EFLAGS
  35.  
  36. cpuid    equ    <db 0Fh,0A2h>    ; P5 info instruction, also handled by new
  37.                 ; 486's (and 386's?)
  38.  
  39. CheckP5        proc
  40. ; checks if P5's cpuid instruction will work ok.
  41.     mov    ax,sp
  42.     push    sp
  43.     pop    bx
  44.     cmp    bx,ax
  45.     jnz    @@noP5
  46.     mov    ax,7000h
  47.     pushf
  48.     push    ax
  49.     popf
  50.     pushf
  51.     pop    ax
  52.     popf
  53.     and    ax,7000h
  54.     jz    @@noP5
  55.     .386
  56.     pushfd
  57.     pop    eax
  58.     mov    ecx,eax
  59.     xor    eax,EF_ID
  60.     push    eax
  61.     popfd
  62.     pushfd
  63.     pop    eax
  64.     push    ecx
  65.     popfd
  66.     and    eax,EF_ID
  67.     and    ecx,EF_ID
  68.     cmp    eax,ecx
  69.     jz    @@noP5
  70.     clr    eax
  71.     inc    al        ; eax = 1, get chip model and features
  72.     cpuid
  73.     jmp    @@Q
  74.     .8086
  75. @@noP5:
  76.     clr    ax
  77. @@Q:
  78.     ret
  79.     endp
  80.  
  81. GetP5Features    proc
  82. ; returns features word
  83.     call    CheckP5
  84.     or    ax,ax
  85.     jz    @@Q
  86.     xchg    dx,ax
  87. @@Q:
  88.     ret
  89.     endp
  90.  
  91.     .386
  92.  
  93. Result    equ    dword ptr [bp+06]
  94.  
  95. GetP5Vendor    proc
  96. ; fills 13-byte buffer at [Result] with Id string
  97.  
  98.     push    bp        ; building up stack frame
  99.     mov    bp,sp
  100.  
  101.     les    di,Result
  102.     call    CheckP5
  103.     or    ax,ax
  104.     jnz    @@GetInfo
  105.     stosb
  106.     jmp    @@Q
  107. @@GetInfo:
  108.     clr    eax        ; get vendor id in [ebx,edx,ecx]
  109.     cpuid
  110.     mov    al,12
  111.     stosb
  112.     xchg    ebx,eax
  113.     stosd
  114.     xchg    edx,eax    
  115.     stosd
  116.     xchg    ecx,eax
  117.     stosd
  118. @@Q:
  119.     pop    bp
  120.     ret
  121.     endp
  122.  
  123.     END
  124.